# -*- coding:utf-8 -*-
def count_words(file_name):
    """计算一个文件大致包含多少个单词"""

    try:
        with open(file_name) as file_object:
            content = file_object.read()

    except FileNotFoundError:
        # pass 直接跳过什么都不做
        message = "Sorry, the file" + file_name +" does not exist."
        print(message)
    else:
        # 计算问价大致包含多少个单词
        words = content.split()
        words_num = len(words)
        print("The file " + file_name + " has about " + str(words_num) + " words")


fileName = './read_file/alice.txt'

count_words(fileName)